package custom.security.wiremock;

import org.springframework.http.HttpStatus;

import static com.github.tomakehurst.wiremock.client.WireMock.*;

/**
 * wireMock是一个可以构建虚拟Api的工具 具体使用下载请百度
 * {@link <a href="http://wiremock.org/"></a>}
 * 发布wireMock 服务
 * 用于api测试
 * Created by security on 2017/9/24.
 */
public class MockServer {

    public static final String getUserResponse = "{\"id\":\"123345123\",\"id\":\"dbasfassad\",\"id\":\"fahba\"}";

    public static void main(String[] args) {
        configureFor(8111);
        removeAllMappings();   //清除之前的所有配置

        //添加一个服务
        stubFor(
                get(urlEqualTo("/user"))    //get请求url 为“/user”
                .willReturn(    //将返回
                        aResponse().withBody(getUserResponse) //一个响应，设置响应体
                                .withStatus(HttpStatus.OK.value())  //设置状态码
                )
        );

    }
}
